﻿@model IEnumerable<Kooboo.CMS.Content.Services.RepositorySendingFolders>
@using Kooboo.CMS.Web.Areas.Contents.Models
@using Kooboo.CMS.Content.Models
@{
    ViewData["InputName"] = "SendingFolder";
    ViewBag.IsSingle = true;
    var treeId = "tree_" + Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(10);
    ViewBag.TreeId = treeId;
}

<div id="@treeId" class="block treeview">
    <ul>
        @foreach (var sending in Model)
        {    
            <li class="repository-node tree-node clearfix">
                <span>
                    <a>
                        @sending.Repository.Name</a>
                    <input type="hidden" disabled="disabled" name="SendingRepository" value="@sending.Repository.Name" />
                </span>
                @Html.IconImage("tree-icon")
                @(Html.Partial("FolderTreeNode", sending.TextFolders, ViewData))

            </li>
        }
    </ul>
</div>
<script>
    $(function () {
        $tree = $('#@treeId');
        $tree.find('li.tree-node').treeNode();
        $tree.find('input[type=radio]').change(function () {
            $('input:hidden[name=SendingRepository]').attr('disabled', 'disabled');
            $(this).parents('li.repository-node').find('input:hidden[name=SendingRepository]').removeAttr('disabled');
        });
    });
</script>
